using System;
using System.Collections.Generic;
using System.Text;

using PickGold;
using PickGold.Database;

namespace PickGold.Entities.Table
{
    public class CBaseLinkInfo : CBaseTable
    {
        //
        public const string ENTITY_NAME = "tb_sys_link_info";
        public const string ENTITY_ALIAS = "links";
        public const string ENTITY_KEY = "link_id";
        public const string ENTITY_SYMBOL = "link_name";
        //
        public const string USER_ID = CBaseUserInfo.ENTITY_KEY;
        public const string ROLE_ID = CBaseRoleInfo.ENTITY_KEY;
        public const string COM_ID = CBaseCompanyInfo.ENTITY_KEY;
        public const string ITEM_TARGET = "item_target";
        public const string ITEM_LOGO = "item_logo";
        public const string ITEM_URL = "item_url";
        public const string SCRIPT_CLICK = "script_click";
        public const string ITEM_REVIEW = "item_review";
        public const string ITEM_ORDER = "item_order";
        //
        private SBaseLinkInfo _ = null;
        //
        public CBaseLinkInfo() : base(ENTITY_NAME, ENTITY_ALIAS) { }
        public CBaseLinkInfo(CDatabase db) : base(db, ENTITY_NAME, ENTITY_ALIAS) { }
        public CBaseLinkInfo(string alias) : base(ENTITY_NAME, alias) { }
        public CBaseLinkInfo(CDatabase db, string alias) : base(db, ENTITY_NAME, alias) { }
        //
        protected override void SetSchema()
        {
            this.SetSchema(new SBaseLinkInfo());
        }
        protected void SetSchema(SBaseLinkInfo s)
        {
            this._ = s;
            base.SetSchema(s);
        }
        //
        protected override void PreInitSchema()
        {
            base.PreInitSchema();
            this._DataTable.Columns.Add(USER_ID, typeof(long)).DefaultValue = this._.UserID;
            this._DataTable.Columns.Add(ROLE_ID, typeof(long)).DefaultValue = this._.RoleID;
            this._DataTable.Columns.Add(COM_ID, typeof(long)).DefaultValue = this._.ComID;
            this._DataTable.Columns.Add(ITEM_TARGET, typeof(string)).MaxLength = 50;
            this._DataTable.Columns.Add(ITEM_LOGO, typeof(string)).MaxLength = 256;
            this._DataTable.Columns.Add(ITEM_URL, typeof(string)).MaxLength = 256;
            this._DataTable.Columns.Add(SCRIPT_CLICK, typeof(string)).MaxLength = 256;
            this._DataTable.Columns.Add(ITEM_REVIEW, typeof(int)).DefaultValue = this._.ItemReview;
            this._DataTable.Columns.Add(ITEM_ORDER, typeof(int)).DefaultValue = this._.ItemOrder;
        }
        //
        #region Property
        //
		[CForeignLink(typeof(CBaseUserInfo))]
        public long UserID
        {
            set
            {
                this._.UserID = value;
                this.SetValue(USER_ID, value);
            }
            get
            {
                return this._.UserID;
            }
        }
        //
		[CForeignLink(typeof(CBaseRoleInfo))]
		public long RoleID
        {
            set
            {
                this._.RoleID = value;
                this.SetValue(ROLE_ID, value);
            }
            get
            {
				return this._.RoleID;
            }
        }
        //
		[CForeignLink(typeof(CBaseCompanyInfo))]
		public long ComID
        {
            set
            {
                this._.ComID = value;
                this.SetValue(COM_ID, value);
            }
            get
            {
				return this._.ComID;
            }
        }
        //
		public string ItemTarget
        {
            set
            {
                this._.ItemTarget = value;
                this.SetValue(ITEM_TARGET, value);
            }
            get
            {
				return this._.ItemTarget;
            }
        }
        //
        public string ItemLogo
        {
            set
            {
                this._.ItemLogo = value;
                this.SetValue(ITEM_LOGO, value);
            }
            get
            {
                return this._.ItemLogo;
            }
        }
        //
        public string ItemUrl
        {
            set
            {
                this._.ItemUrl = value;
                this.SetValue(ITEM_URL, value);
            }
            get
            {
                return this._.ItemUrl;
            }
        }
        //
        public string ScriptClick
        {
            set
            {
                this._.ScriptClick = value;
                this.SetValue(SCRIPT_CLICK, value);
            }
            get
            {
                return this._.ScriptClick;
            }
        }
        //
        public int ItemReview
        {
            set
            {
                this._.ItemReview = value;
                this.SetValue(ITEM_REVIEW, value);
            }
            get
            {
                return this._.ItemReview;
            }
        }
        //
        public int ItemOrder
        {
            set
            {
                this._.ItemOrder = value;
                this.SetValue(ITEM_ORDER, value);
            }
            get
            {
                return this._.ItemOrder;
            }
        }
        //
        #endregion
        //
        public override bool MoveTo(int position)
        {
            if (!base.MoveTo(position))
                return false;

            this._.UserID = this.GetValue<long>(USER_ID, true);
            this._.RoleID = this.GetValue<long>(ROLE_ID, true);
            this._.ComID = this.GetValue<long>(COM_ID, true);
            this._.ItemTarget = this.GetValue<string>(ITEM_TARGET, true);
            this._.ItemLogo = this.GetValue<string>(ITEM_LOGO, true);
            this._.ItemUrl = this.GetValue<string>(ITEM_URL);
            this._.ScriptClick = this.GetValue<string>(SCRIPT_CLICK, true);
            this._.ItemReview = this.GetValue<int>(ITEM_REVIEW);
            this._.ItemOrder = this.GetValue<int>(ITEM_ORDER);
            return true;
        }
        //
    }
    //
    public class SBaseLinkInfo : SBaseTable
    {
        //
        public long UserID = -1;
        public long RoleID = -1;
        public long ComID = -1;
		public string ItemTarget = null;
        public string ItemLogo = null;
        public string ItemUrl = null;
        public string ScriptClick = null;
        public int ItemReview = 0;
        public int ItemOrder = 0;
        //
    }
    //
}
//
